package process_demo.timer;

/**
 * @author haomin
 * @date 2022/05/03 18:25
 **/
public class ImplTimer  {
    static class MyThread extends Thread{
        Runnable task;
        long delay;

        MyThread(Runnable task,long delay){
            this.task = task;
            this.delay = delay;
        }

        @Override
        public void run() {
            try {
                Thread.sleep(delay);
                task.run();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args) {
        Runnable task = new Runnable() {
            @Override
            public void run() {
                System.out.println("时间到");
            }
        } ;
        MyThread myThread = new MyThread(task,1000);
        myThread.start();
        while (true){}
    }
}